{include file='public/meta'}
<title>管理员分组</title>
</head>
<body>
{include file='public/header'}
{include file='public/menu'}

<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> {$controller} <span class="c-gray en">&gt;</span> {$action} <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray"> <span class="l">
					<a href="javascript:;" onclick="batchdel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
					<a id="group_add" class="btn btn-primary radius" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加角色</a>
				</span>
				<span class="r">共有数据：<strong>{$data|count}</strong> 条</span> </div>
			<div class="mt-10">
			<table class="table table-border table-bordered table-hover table-bg">
				<thead>
					<tr>
						<th scope="col" colspan="6">角色管理</th>
					</tr>
					<tr class="text-c">
						<th width="25"><input type="checkbox" value="" name=""></th>
						<th width="40">ID</th>
						<th width="200">角色名</th>
						<th>用户列表</th>
						<th width="300">描述</th>
						<th width="70">操作</th>
					</tr>
				</thead>
				<tbody>
					{volist name="data" id="vo"}
					<tr class="text-c">
						<td><input type="checkbox" value="{$vo.gid}" name=""></td>
						<td>{$vo.gid}</td>
						<td>{$vo.gname}</td>
						<td>
						{present name="group_member[$vo.gid]"}
							{volist name="group_member[$vo.gid]" id="va"}
							<a class="m_info" href="javascript:;"><span style="display:none;">{$va.uid}</span>{$va.uname}&nbsp;</a>
							{/volist}
						{else}
						暂无
						{/present}
						</td>
						<td>{$vo.des}</td>
						<td class="td-manage">
							<a style="text-decoration:none" class="ml-5" onClick="group_edit(this,{$vo.gid})" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
							<a style="text-decoration:none" class="ml-5" onClick="group_del(this,{$vo.gid})" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			</div>
		</article>
	</div>
</section>

{include file='public/footer'}
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
	$('.m_info').click(function(){
		var id = $(this).children().text();
		layer_show('个人简信','{:url('admin/member/m_info')}'+'?uid='+id,'350','240');
	});

	$('#group_add').click(function(){
		// layer_show('添加角色','{:url('admin/member/group_add')}','550','500');
		layer.open({
			type: 2,
			area: ['550px', '500px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: '添加角色',
			content: '{:url('admin/member/group_add')}',
			end:function(){
				location.href = '{:url('admin/member/member_group')}';
			}
		});
	})
	
	//批量删除
	function batchdel(){
		var re = '';
		$('input[type=checkbox]:checked').each(function(){
			re += $(this).val()+',';
		})
		var data = 'gid='+re;
		$.post('{:url('admin/member/do_groupdel')}',data,function(res){
			console.log(res);
		})
		$('input[type=checkbox]:checked').parents("tr").remove();
		if(re == ''){
			layer.msg('未选中任何记录!',{icon:1,time:1000});
		}else{
			location.reload();
			layer.msg('批量删除成功!',{icon:1,time:1000});
		}
	}

	//单个删除
	function group_del(obj,id){
		layer.confirm('确认要删除吗？',{icon:3,title:'提示'},function(index){
			var data = 'gid='+id;
			$.post('{:url('admin/member/do_groupdel')}',data,function(res){
				console.log(res);
			})
			$(obj).parents("tr").remove();
			layer.msg('已删除!',{icon:1,time:1000});
		});
	}

	//单个编辑
	function group_edit(obj,id){
		// layer_show('编辑角色','{:url('admin/member/group_edit')}'+'?gid='+id,'550','500');
		layer.open({
			type: 2,
			area: ['550px', '500px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: '编辑角色',
			content: '{:url('admin/member/group_edit')}'+'?gid='+id,
			end:function(){
				location.href = '{:url('admin/member/member_group')}';
			}
		});
	}




</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>